package com.ufind.common.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * 性别的枚举类型
 * Created by xuliugen on 2016/3/13.
 */
public enum ESexType {

    MALE(1, "男"),
    FEMALE(2, "女");

    public Integer code;
    public String value;

    ESexType(Integer value, String desc) {
        this.code = value;
        this.value = desc;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public static ESexType getTypeByVal(Integer value) {
        ESexType defaultState = MALE;
        for (ESexType eRecordState : ESexType.values()) {
            if (eRecordState.code.equals(value)) {
                return eRecordState;
            }
        }
        return defaultState;
    }

    public static String getDescByVal(Integer value) {
        return getTypeByVal(value).value;
    }

    public static Map<Integer, String> getSexTypesMap() {
        Map<Integer, String> sexTypesMap = new HashMap<Integer, String>();
        for (ESexType sexType : ESexType.values()) {
            sexTypesMap.put(sexType.getCode(), sexType.getValue());
        }
        return sexTypesMap;
    }
}
